package com.house.api.config;

import com.house.api.interceptor.JwtTokenUserInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
@Slf4j
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Autowired
    private JwtTokenUserInterceptor jwtTokenUserInterceptor;

    /**
     * 注册自定义拦截器
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("开始注册自定义拦截器");
        registry.addInterceptor(jwtTokenUserInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/user/code")
                .excludePathPatterns("/user/iscode")
                .excludePathPatterns("/house/search/**")
                .excludePathPatterns("/house/list")
                .excludePathPatterns("/house/info/**")
                .excludePathPatterns("/house/hotsearch")
                .excludePathPatterns("/history/add")
                .excludePathPatterns("/swagger**")
                .excludePathPatterns("/equipment/equipmentList");

    }

}
